package com.example.javatwo.service.cg.yt;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.example.javatwo.mapper.cg.yt.CgqgdMapper;
import com.example.javatwo.pojo.cg.yt.DsDataSet1;
import com.example.javatwo.util.PageBead;

@Service
public class CgqgdService {
	@Autowired
	private CgqgdMapper cgqgdMapper;
	
	public PageBead list(int sum){
		int q=cgqgdMapper.sum();
		List<DsDataSet1> dslist=cgqgdMapper.list(sum-1);
		for (DsDataSet1 dsDataSet1 : dslist) {
			dsDataSet1.setDsDataSet2s(cgqgdMapper.list2(dsDataSet1.getBillNo()));
		}
		PageBead page = new PageBead(1, q , sum , 1 , dslist);
		System.out.println(page);
		return page;
	}
	@Transactional
	public void add(DsDataSet1 dataSet1){
		cgqgdMapper.add(dataSet1);
		cgqgdMapper.addInfo(dataSet1);
	}
	
	@Transactional
	public void update(DsDataSet1 dataSet1){
		cgqgdMapper.deleteInfo(dataSet1.getBillNo());
		cgqgdMapper.addInfo(dataSet1);
		cgqgdMapper.update(dataSet1);
	}
	
	@Transactional
	public void del(String billNo){
		cgqgdMapper.delete(billNo);
	}
	 
	public String auditing(String billNo){
		if(cgqgdMapper.findSet1(billNo).equals("是")){
			System.out.println("近");
			return null;
		}
		cgqgdMapper.setYnAudit(billNo,"是");
		return "审核成功";
	}
	public String auditing1(String billNo){
		if(cgqgdMapper.findSet1(billNo).equals("否")){
			System.out.println("近");
			return null;
		}
		cgqgdMapper.setYnAudit(billNo,"否");
		
		return "反審核成功";
	}
}
